diff --git a/setup.py b/setup.py
index 3d499983f..60b760634 100644
--- a/setup.py
+++ b/setup.py
@@ -21,7 +21,7 @@ install_requires = [
     'sphinxcontrib-htmlhelp',
     'sphinxcontrib-serializinghtml',
     'sphinxcontrib-qthelp',
-    'Jinja2>=2.3',
+    'Jinja2<3.1',
     'Pygments>=2.0',
     'docutils>=0.12',
     'snowballstemmer>=1.1',
diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py
index 1783db491..a9cc89eee 100644
--- a/sphinx/domains/cpp.py
+++ b/sphinx/domains/cpp.py
@@ -6089,9 +6089,22 @@ class DefinitionParser(BaseParser):
                     # TODO: it would be nice to save the previous stacktrace
                     #       and output it here.
                     if True:
+                        # Define a regex pattern for GNU style attributes
+                        _gnu_attribute_regex = re.compile(r'__attribute__\s*\(\(.*?\)\)')
+                        # Check for GNU style attributes and handle them
+                        attribute_match = self.match(_gnu_attribute_regex)
+                        if attribute_match:
+                            # Found a GNU style attribute, consume it and continue
+                            self.pos += len(attribute_match.group(0))
+                        else:
+                            # No GNU style attribute, proceed with regular parsing
+                            try:
+                                self._parse_attribute()
+                            except DefinitionError:
+                                pass
+
                         if outer == 'type':
-                            header = "Type must be either just a name or a "
-                            header += "typedef-like declaration."
+                            header = "Type must be either just a name or a typedef-like declaration."
                         elif outer == 'function':
                             header = "Error when parsing function declaration."
                         else:
diff --git a/tox.ini b/tox.ini
index d9f040544..bf39854b6 100644
--- a/tox.ini
+++ b/tox.ini
@@ -28,7 +28,7 @@ extras =
 setenv =
     PYTHONWARNINGS = all,ignore::ImportWarning:importlib._bootstrap_external,ignore::DeprecationWarning:site,ignore::DeprecationWarning:distutils
 commands=
-    pytest --durations 25 {posargs}
+    pytest -rA --durations 25 {posargs}
 
 [testenv:flake8]
 basepython = python3
